<template>
	<view>
		<view class="header">
			<x-status-bar></x-status-bar>
			<view class="flex-center-between header-navbar">
				<x-back-btn></x-back-btn>
				<view class="u-f-40 common-title">{{ title }}</view>
				<view></view>
			</view>
		</view>
		
		<x-parse :content="content"></x-parse>
	</view>
</template>

<script>
	import { noticeInfo, Info } from '@/api/base.js'
	const types = [
		{ label: '隐私政策', key: 'privacy', value: 'key.private.policy' },
		{ label: '用户协议', key: 'policy', value: 'key.user.policy' },
		{ label: '平台声明', key: 'statement', value: 'key.platform.statement' },
		{ label: '公告详情', key: 'notice' },
		{ label: 'cookie政策', key: 'cookie', value: 'key.user.cookie' },
		{ label: '用户兑换协议', key: 'exchange', value: 'key.exchange.agreement' },
	]
	export default {
		data() {
			return {
				title: '',
				content: '',
				subnvue: null
			}
		},
		onLoad({ type, noticeId }) {
			// #ifdef APP-PLUS
			if (type === 'notice') {
				noticeInfo({ noticeId }).then((result) => {
					this.initInfo(result)
				})
			} else {
				let obj = types.find(item => item.key === type)
				Info({ key: obj.value }).then((result) => {
					this.initInfo(result)
				})
			}
			// #endif
		},
		methods: {
			initInfo({ title, content }) {
				this.$set(this, 'title', title)
				this.$set(this, 'content', content)
			}
		}
	}
</script>

<style scoped lang="scss">

</style>
